import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);
import vuexPersist from "vuex-persist";
export default new Vuex.Store({
  state: {
    active: -1,
    list: 0,
user:[],//登陆的用户
pic:[],//购物车数据
  },
  mutations: {
    blue(state, i) {
      state.active = i
    },
    dian(state, i) {
      if (state.list == i) {
        state.list = 0;
      } else {
        state.list = i;
      }
    },
    setUser(state,data){
      state.user=data
    },
    //购物车数据
    picss(state,playout){
      state.pic=playout
    }
  },
  getters:{
    getUser(state){
      return state.user
    }
  },
  actions: {
    setUser ({ commit }, data) {
      commit('setUser', data);
    },
  },
  modules: {},
  plugins: [
    new vuexPersist({
      localstorage: window.localStorage,
    }).plugin,
  ],
});
